import collections
class Solution(object):
    def findPairs(self, nums, k):


        if k<0 or len(nums)==0:
            return 0
        res=0
        d = collections.Counter(nums)
        for i in d:
            if i+k in d:
                if (k==0 and d[i]>=2) or k>0:
                    res+=1
        return res


a=  [3,1,4,1,5]
s= Solution()
print(s.findPairs(a,2))